/*-------------------<-- Start of Description-->---------------------\ | Read in comma delimited string; comma in a bracket will not be | | used as an delimiter; | |---------------------<-- End of Description-->----------------------| |--------------------------------------------------------------------| |------------<-- Start of Files or Arguments Needed-->---------------| | Argument: | | _string_: the _string_; | | | | output: this function returns a translated string, after you read | | the comma delimited parameters, you will have to do some | | translation works: | | À back to (, Á back to ), ´ back to ',', ® back to ' '; | |-------------<-- End of Files or Arguments Needed-->----------------| |--------------------------------------------------------------------| |------------------<-- Start of Files Created-->---------------------| | Example: %put %xread(this is a test(distinct rassignn, visit, | | count(distinct pt) as totpt)); | | Usage: %xread(_string_); | \-------------------<-- End of Files Created-->---------------------*/ %macro xread(_string_); /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 8-12-2002 9:11pm; | | Modified: 11-16-2002 2:22pm; | | Purpose: Read in comma delimited string; | \--------------------------------------------*/ %local _string_; %if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_string_))))), %str(%()) eq 1) and (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_string_))))))), %str(%))) eq 1) %then %let _string_=%substr(%quote(%trim(%quote(%left(%quote(&_string_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_string_)))))-2)); %put _string_: &_string_; %let _xrx_=%sysfunc(rxparse($(1))); %let _xpos_=0; %let _xlen_=0; %let _xoldstr_=; %let _xnewstr_=; %do %while( %sysfunc(rxmatch(&_xrx_, %quote(&_string_))) ); %syscall rxsubstr(_xrx_, _string_, _xpos_, _xlen_); %let _xoldstr_=%quote(%substr(%quote(&_string_), &_xpos_, &_xlen_)); %let _xnewstr_=%quote(%sysfunc(translate(%quote(&_xoldstr_), À, %quote(%(), Á, %quote(%)), ´, %quote(,), ®, %quote( )))); %let _string_=%sysfunc(tranwrd(%quote(&_string_), %quote(&_xoldstr_), %quote(&_xnewstr_))); %let _xpos_=0; %let _xlen_=0; %let _xoldstr_=; %let _xnewstr_=; %end; &_string_; %mend xread;